package org.amicofragile.test.springintegration.client;

import java.text.MessageFormat;

import org.amicofragile.test.springintegration.dto.Person;
import org.amicofragile.test.springintegration.gateway.HelloGateway;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("myClient")
public class MyClient implements HelloClient
{
	private static final Log LOG = LogFactory.getLog(MyClient.class);

	private HelloGateway helloGateway;

	@Autowired(required = true)
	public MyClient(HelloGateway helloGateway)
	{
		this.helloGateway = helloGateway;
	}

	public String getHelloMessageFor(final Person person)
	{
		if (LOG.isDebugEnabled())
		{
			LOG.debug(MessageFormat.format("MyClient.getHelloMessageFor({0})", person.toString()));
		}
		this.helloGateway.sayHelloTo(person);
		return "OK";
	}
}
